<script setup lang="ts">
import { reactive } from "vue";
import service from "../../../utils/service";
interface IGoods {
    userid: string,
    name: string,
    tel: number,
    province: string,
    city: string,
    county: string,
    addressDetail: number,
    isDefault: boolean,
    addressid: string,
}
const addresslist = reactive<IGoods[]>([]);
    const getaddresslist = () => {
    service({
        url: "/address/list",
    })
        .then(res => {
            if (res.data.code == "200") {
                // addresslist.isDefault= res.data.isDefault
                addresslist.length = 0;
                addresslist.push(...res.data.data);
            }
        })
}
getaddresslist();
const updated = ()=>{
    // isDefault= res.data.isDefault
}
</script>

<template>
    <h3>地址列表</h3>
    <el-table :data="addresslist" style="width: 100%">
        <el-table-column prop="userid" label="编号" width="200" />
        <el-table-column prop="name" label="名称" width="100" />
        <el-table-column prop="tel" label="电话" width="160" />
        <el-table-column prop="province" label="省份" width="80" />
        <el-table-column prop="city" label="城市" width="80" />
        <el-table-column prop="county" label="区域" width="100" />
        <el-table-column prop="addressDetail" label="详细地址" width="100" />
        <el-table-column label="是否默认" width="180">
            <template #default="scope">
                <el-switch v-model="scope.row.isDefault" @change="updated" />
            </template>
        </el-table-column>
        <el-table-column prop="addressid" label="详细地址" width="100" />
    </el-table>
</template>

<style scoped></style>